package keeto.com.vn.bms.network.task;

import java.io.IOException;

import keeto.com.vn.bms.config.IBMSCore;
import keeto.com.vn.bms.network.IBMSProtocol;
import keeto.com.vn.bms.network.request.PoseNotParticipateRequest;
import keeto.com.vn.bms.network.response.PoseNotParticipateReponse;
import keeto.com.vn.bms.utils.BMSListener;

import org.apache.http.client.ClientProtocolException;
import org.json.JSONException;

public class TaskPoseNotParticipate extends AbstractTask{
	String status_id;
	String iD;
	String reason;
	String userAuthKey;
	
	public TaskPoseNotParticipate(BMSListener listener, IBMSCore core,
			String status_id, String iD,String reason, String userAuthKey) {
		super(listener, core);
		this.status_id = status_id;
		this.iD = iD;
		this.reason = reason;
		this.userAuthKey = userAuthKey;
	}
	
	@Override
	public void run() throws ClientProtocolException, JSONException, IOException {
		PoseNotParticipateRequest request = new PoseNotParticipateRequest();
		request.setiD(iD);
		request.setStatus_id(status_id);
		request.setUserAuthKey(userAuthKey);
		request.setReason(reason);
		PoseNotParticipateReponse reponse = protocol.getPoseNotParticipate(request);
		for (BMSListener mListener : listener){
			mListener.finishPoseNotParticipate(reponse.getReturnCode(), reponse.getResultMsg());
		}
	}

	@Override
	public void timeoutCallback() {
		for (BMSListener mListener : listener){
			mListener.finishPoseNotParticipate(IBMSProtocol.STATUS_CODE_GENERIC_FAIL_CONECTTION,"");
		}
	}

}
